package Chapter03;
//1000内的完数
public class Question4 {
    public static void main(String[] args) {
        System.out.println("1000内所有完数: " );
        for (int i = 1; i <= 1000; i++) {
            if (Isperfectnum(i)) {
                System.out.println(i+"");
            }
        }
    }
    private static boolean Isperfectnum(int num) {
        int sum = 0;
        for (int j = 1; j < num; j++) {
            if (num % j == 0) {
                sum += j;
            }
        }
        return sum == num;
    }
}
